package com.qianfeng.zhangwei.blutooth.jiami;

import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.qianfeng.zhangwei.blutooth.R;
import com.qianfeng.zhangwei.blutooth.jiami.ase.AesUtils;
import com.qianfeng.zhangwei.blutooth.jiami.base64.Base64Utils;
import com.qianfeng.zhangwei.blutooth.jiami.md5.MD5Uutils;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

/**
 *
 */
@EActivity(R.layout.activity_encrypt)
public class EncryptActivity extends AppCompatActivity {
    @ViewById
    TextView msg;
    @ViewById
    Button md5Btn;
    @ViewById
    Button aesEncryptBtn;
    @ViewById
    Button aesDecodeBtn;
    @ViewById
    Button base64EncodeBtn;
    @ViewById
    Button base64DecodeBtn;
    private String str = "花开花落不变寻梦之心, 虫死虫生待语话之时!";
    private String text;
//    @ViewsById({R.id.md5_btn, R.id.aes_encrypt_btn, R.id.aes_decode_btn, R.id.base64_encode_btn, R.id.base64_decode_btn})
//    Button md5Btn;
//    Button aseEncryptBtn;
//    Button aseDecodeBtn;
//    Button base64EncryptBtn;
//    Button base64DecodeBtn;
    @Click({R.id.md5_btn, R.id.aes_encrypt_btn, R.id.aes_decode_btn, R.id.base64_encode_btn, R.id.base64_decode_btn})
    public void onClick(View view) {


        switch (view.getId()) {
            case R.id.md5_btn:
                text = MD5Uutils.MD5(str);
                break;
            case R.id.aes_encrypt_btn:
                text = AesUtils.encrypt(str);
                break;
            case R.id.aes_decode_btn:
                text = AesUtils.decrypt(text);
                break;
            case R.id.base64_encode_btn:
                text = Base64Utils.encode(str.getBytes());
                break;
            case R.id.base64_decode_btn:
                text = new String(Base64Utils.decode(str));
                break;
        }
        msg.setText(text);

    }


}
